﻿//-----------------------------------------------------------------------
// <copyright file="Copyright.cs" author="Michael Herndon">
//     Copyright (c) Michael Herndon.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Amplify.Twitter
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;
	using System.ServiceModel.Security;

	/// <summary>
	/// Manages creating and destroying notifications of a
	/// specified user.
	/// </summary>
	public class NotificationClient : TwitterClient<INotificationClient>, INotificationClient 
	{

		/// <summary>
		/// Initializes a new instance of the <see cref="NotificationClient"/> class.
		/// </summary>
		/// <param name="username">The username.</param>
		/// <param name="password">The password.</param>
		public NotificationClient(string username, string password)
			: base(username, password)
		{

		}

		#region INotificationClient Members

		/// <summary>
		/// Creates (Follows) a notification
		/// </summary>
		/// <param name="id">The screen name or id of the user.</param>
		/// <returns>a <see cref="Amplify.Twitter.User"/> object. </returns>
		/// <exception cref="System.ServiceModel.Security.MessageSecurityException" />
		/// <exception cref="Amplify.Twitter.TwitterException"> Throws when a twitter error occurs. </exception>
		public User Create(string id)
		{
			try
			{
				return this.Proxy.Create(id);
			}
			catch (MessageSecurityException securityException)
			{
				this.Rescue(securityException);
				return null;
			}
		}

		/// <summary>
		/// Destroys (leaves) a notfication.
		/// </summary>
		/// <param name="id">The screen name or id of the user.</param>
		/// <returns>a <see cref="Amplify.Twitter.User"/> object. </returns>
		/// <exception cref="System.ServiceModel.Security.MessageSecurityException" />
		/// <exception cref="Amplify.Twitter.TwitterException"> Throws when a twitter error occurs. </exception>
		public User Destroy(string id)
		{
			try
			{
				return this.Proxy.Destroy(id);
			}
			catch(MessageSecurityException securityException) 
			{
				this.Rescue(securityException);
				return null;
			}
	
		}

		#endregion
	}
}
